import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { SMiniGuildInfo } from "../../../../Message/Game/SMiniGuildInfo";
import { GuildConfig } from "../../resource/GuildConfig";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { GButton } from "../../../../com/mui/controls/GButton";
import { Language } from "../../../../extend/language/Language";
import { Alert } from "../../../../com/mui/controls/Alert";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { CustomAlertWin } from "../common/alertwins/CustomAlertWin";
type int = number;
//class InviteGuildRender
    
    export  class InviteGuildRender extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=0;
            super.data = arg1;
            this._sMiniGuildInfo = arg1 as SMiniGuildInfo;
            loc1 = GuildConfig.instance.getMaxNumByLevel(this._sMiniGuildInfo.level);
            this.nameTxt.text = this._sMiniGuildInfo.guildName;
            this.campTxt.text = GameDefConfig.instance.getECamp(this._sMiniGuildInfo.camp);
            this.chairmanTxt.text = this._sMiniGuildInfo.leaderName;
            this.levelTxt.text = this._sMiniGuildInfo.level.toString();
            this.numberTxt.text = this._sMiniGuildInfo.playerNum.toString() + "/" + loc1.toString();
            if (this._sMiniGuildInfo.guildId in InviteGuildRender.dealDict) 
            {
                this.agreeInviteBtn.enabled = InviteGuildRender.dealDict[this._sMiniGuildInfo.guildId];
                this.refuseInviteBtn.enabled = InviteGuildRender.dealDict[this._sMiniGuildInfo.guildId];
            }
            else 
            {
                this.agreeInviteBtn.enabled = true;
                this.refuseInviteBtn.enabled = true;
            }
            this.agreeInviteBtn.drawNow();
            this.refuseInviteBtn.drawNow();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=0;
            loc1 = 11661567;
            this.nameTxt = new Object /* flash.text.TextField */();
            this.nameTxt.x = 10;
            this.nameTxt.y = 0;
            this.nameTxt.height = 30;
            this.nameTxt.selectable = false;
            this.nameTxt.textColor = loc1;
            this.nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            addChild(this.nameTxt);
            this.campTxt = new Object /* flash.text.TextField */();
            this.campTxt.x = 100;
            this.campTxt.y = 0;
            this.campTxt.height = 30;
            this.campTxt.selectable = false;
            this.campTxt.textColor = loc1;
            this.campTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            addChild(this.campTxt);
            this.chairmanTxt = new Object /* flash.text.TextField */();
            this.chairmanTxt.x = 170;
            this.chairmanTxt.y = 0;
            this.chairmanTxt.height = 30;
            this.chairmanTxt.selectable = false;
            this.chairmanTxt.textColor = loc1;
            this.chairmanTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            addChild(this.chairmanTxt);
            this.levelTxt = new Object /* flash.text.TextField */();
            this.levelTxt.x = 235;
            this.levelTxt.y = 0;
            this.levelTxt.height = 30;
            this.levelTxt.width = 35;
            this.levelTxt.selectable = false;
            this.levelTxt.textColor = loc1;
            this.levelTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            addChild(this.levelTxt);
            this.numberTxt = new Object /* flash.text.TextField */();
            this.numberTxt.x = 310;
            this.numberTxt.y = 0;
            this.numberTxt.height = 30;
            this.numberTxt.width = 60;
            this.numberTxt.selectable = false;
            this.numberTxt.textColor = loc1;
            this.numberTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            addChild(this.numberTxt);
            this.agreeInviteBtn = new GButton();
            this.agreeInviteBtn.label = Language.getString(57031);
            this.agreeInviteBtn.styleName = "Button";
            this.agreeInviteBtn.setSize(67, 24);
            this.agreeInviteBtn.move(365, 0);
            this.agreeInviteBtn.drawNow();
            this.agreeInviteBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onAgreeInviteBtnClickHandler);
            addChild(this.agreeInviteBtn);
            this.refuseInviteBtn = new GButton();
            this.refuseInviteBtn.label = Language.getString(57032);
            this.refuseInviteBtn.styleName = "Button";
            this.refuseInviteBtn.setSize(50, 24);
            this.refuseInviteBtn.move(435, 0);
            this.refuseInviteBtn.drawNow();
            this.refuseInviteBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onRefuseInviteBtnClickHandler);
            addChild(this.refuseInviteBtn);
            this.graphics.moveTo(10, 25);
            this.graphics.lineStyle(0.8, 282466);
            this.graphics.lineTo(475, 25);
            return;
        }

        /* internal  */onAgreeInviteBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            var e: Object /* flash.events.Event */;
            var htmlContent: string;
            var htmlTitle: string;
            var onClickHandler: Function;

            var loc1;
            onClickHandler = null;
            e = arg1;
            onClickHandler = (arg1: int): void
            {
                if (arg1 != Alert.OK) 
                {
                    agreeInviteBtn.enabled = true;
                }
                else 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GuildDealInvite, {"guildId": _sMiniGuildInfo.guildId, "oper": true}));
                    Alert.resetToDefault();
                    agreeInviteBtn.enabled = false;
                }
                return;
            }
            htmlContent = Language.getStringByParam(57033, this._sMiniGuildInfo.guildName);
            htmlTitle = Language.getString(57034);
            Alert.backgroundAlpha = 0;
            Alert.alertWinRenderer = CustomAlertWin;
            Alert.show(htmlContent, htmlTitle, Alert.OK | Alert.CANCEL, null, onClickHandler);
            return;
        }

        /* internal  */onRefuseInviteBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            this.agreeInviteBtn.enabled = false;
            this.refuseInviteBtn.enabled = false;
            InviteGuildRender.dealDict[this._sMiniGuildInfo.guildId] = false;
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildDealInvite, {"guildId": this._sMiniGuildInfo.guildId, "oper": false}));
            return;
        }

        /* internal */ /* var */nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */campTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */chairmanTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */levelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */numberTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */agreeInviteBtn: GButton;

        /* internal */ /* var */refuseInviteBtn: GButton;

        /* internal */ /* var */_sMiniGuildInfo: SMiniGuildInfo;

        public static /* var */dealDict: Map<any, any> /* flash.utils.Dictionary */;
    }

            InviteGuildRender.dealDict = new Map<any, any> /* flash.utils.Dictionary */();
        